﻿var gSubmitTimes = 0;
function oLogin()
{
}
function chkLogin(){
	if(gSubmitTimes>2){
		alert('请想想密码再来');
		return;
	}
	var uName="";
	var uPass="";
	var uCode="";
	uName=$("#txtUserName").val();
	uPass=$("#txtUserPass").val();
	uCode=$("#txtUserCode").val();
	if(uName==""){
		alert('请填写用户名');
		$("#txtUserName").focus();
		return;
	}
	if(uPass==""){
		alert('请填写密码');
		$("#txtUserPass").focus();
		return;
	}
	if(uCode==""){
		alert('请填写验证码');
		$("#txtUserCode").focus();
		return;
	}
	var typeNum;
	var rbType=$("#loginform input");
	for(var i=0;i<rbType.length;i++)
	{
		if(rbType[i].checked && rbType[i].type=="radio" && rbType[i].name=="LoginType"){
			typeNum=rbType[i].value;
		}
	}
	$.ajax({
		type:		"post",
		dataType:	"html",
		url:		site.Dir + "user/otherfiles/ajax.aspx?oper=login&time="+(new Date().getTime()),
		data:		"name="+escape(uName)+"&pass="+escape(uPass)+"&code="+escape(uCode)+"&type="+typeNum,
        		error:		function(XmlHttpRequest,textStatus, errorThrown) { alert(XmlHttpRequest.responseText);},
		success:	function(d){
			if (d== "ok")
				top.location.href=$("#txtRefer").val();
			else
			{
				gSubmitTimes=gSubmitTimes+1;
				alert(d);
			}
		}
	});
}
function chkLogout(){
	top.location.href=site.LogoutUrl;
}
function sendRequest(p){
	if(p==0)
	{
		oLogin();
		return;
	}
	$.ajax({
		url:		site.Dir + "user/otherfiles/ajax.aspx?time="+(new Date().getTime()),
		type:		"get",
		dataType:	"json",
		success:	function(d){
			if(d.result=="1")
				if(q('refer')!="")
					top.location.href=unescape(q('refer'));
				else
					top.location.href=site.Dir + 'user/index';
			else
				oLogin();
		}
	});
}